home *** CD-ROM | disk | FTP | other *** search
- Path: freenet.vancouver.bc.ca!zipz
- From: zipz@opus.freenet.vancouver.bc.ca (Patrick Wong)
- Newsgroups: comp.lang.c
- Subject: argc/argv & switches
- Date: 28 Feb 1996 21:59:47 GMT
- Organization: Vancouver Regional FreeNet
- Message-ID: <4h2j8j$9gn@milo.freenet.vancouver.bc.ca>
- NNTP-Posting-Host: opus.freenet.vancouver.bc.ca
- X-Newsreader: TIN [version 1.2 PL2]
-
- I would like to know the difference between *++argv[0] and (*++argv)[0].
- Also, I've seen a lot of programs that have command-line switches like:
-
- view -r -x list.txt
- view -rx list.txt
- view -xr list.txt
-
- How can I write the view program so that it can accept all three formats?
- It has something to do with the *argv[0] parameter, I know that much. I
- looked at K&R and found the example program confusing (find -n -l pattern).
-
- The view program would look like this:
- /* begin program */
- #include <stdio.h>
- main()
- {
- int c;
- while ((c = getchar()) != EOF)
- putchar(c);
- } /* ok, so it's a simple program... */
- /* end program */
-
- How can this program be modified to use -r and -x?
- -x : pause after a screenful of text. If less than screnful, ignore
- -r : put line numbers in front of each line of text.
-
- This program is just something that will help me understand how the
- *argv[0] thing works. Thanks.
-
- Patrick
-
- --
-
- /* Name : Patrick Wong : "You can't legislate public */
- /* E-mail : zipz@freenet.vancouver.bc.ca : opinion; but somehow, the */
- /* Occupation : Student/Programmer : government seems to get away */
- /* School : BCIT - Computer Systems : with it!" */
-